﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Text;
using BUS;
using DTO;
namespace GUI
{
    public partial class _Default : System.Web.UI.Page
    {
        public  void ThongBaoLoi()
        {
            Response.ContentType = "text/xml";
            Response.Write("<?xml version='1.0' encoding='utf-8' ?>");
            Response.Write("<ThongTinKetXe>");            
            Response.Write("</ThongTinKetXe>");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                String query = Request.QueryString["diaDiem"];
                if (query != null&&query.Equals("")==false)
                {
                    List<DiaDiemDTO> listInfo = new List<DiaDiemDTO>();
                    listInfo = DiaDiemBUS.danhSachDiaDiemTheoQuery(query, Server.MapPath("~/App_Data/DuLieuGiaoThong.xml"));
                    Response.ContentType = "text/xml";
                    Response.Write("<?xml version='1.0' encoding='utf-8' ?>");
                    Response.Write("<ThongTinKetXe>");
                    for (int i = 0; i < listInfo.Count; i++)
                    {
                        DiaDiemDTO diaDiemKetXe = (DiaDiemDTO)listInfo[i];
                        String ketQua = "<DiaDiem tenDiaDiem='" + diaDiemKetXe.getTenDiaDiem() + "' Lat='" + diaDiemKetXe.getLat() + "' Lng='" + diaDiemKetXe.getLng() + "' loaiThongTin='" + diaDiemKetXe.getLoaiThongTin() + "'/>";
                        Response.Write(ketQua);
                    }
                    Response.Write("</ThongTinKetXe>");
                }
                else
                {
                    ThongBaoLoi();
                }
            }
            catch (Exception ex)
            {
                ThongBaoLoi();
            }
        }
    }
}
